// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <cstdint>
#include <memory>

#include <nebula/json/type_fwd.h>
#include <turbo/base/macros.h>
#include <nebula/types/type_fwd.h>

namespace nebula::json {

    enum class UnexpectedFieldBehavior : char {
      /// Unexpected JSON fields are ignored
      Ignore,
      /// Unexpected JSON fields error out
      Error,
      /// Unexpected JSON fields are type-inferred and included in the output
      InferType
    };

    struct TURBO_EXPORT ParseOptions {
      // Parsing options

      /// Optional explicit schema (disables type inference on those fields)
      std::shared_ptr<Schema> explicit_schema;

      /// Whether objects may be printed across multiple lines (for example pretty-printed)
      ///
      /// If true, parsing may be slower.
      bool newlines_in_values = false;

      /// How JSON fields outside of explicit_schema (if given) are treated
      UnexpectedFieldBehavior unexpected_field_behavior = UnexpectedFieldBehavior::InferType;

      /// create parsing options with default values
      static ParseOptions defaults();
    };

    struct TURBO_EXPORT ReadOptions {
      // Reader options

      /// Whether to use the global CPU thread pool
      bool use_threads = true;
      /// Block size we request from the IO layer; also determines the size of
      /// chunks when use_threads is true
      int32_t block_size = 1 << 20;  // 1 MB

      /// create read options with default values
      static ReadOptions defaults();
    };

}  // namespace nebula::jsonm

